home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 9772 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.9 KB  |  50 lines

  1. Newsgroups: comp.lang.c++
  2. Path: phcoms4.seri.philips.nl!newssvr!news
  3. From: heydenj@bothrops.natlab.research.philips.com (Heijden van der J.)
  4. Subject: Re: Class
  5. Sender: news@natlab.research.philips.com (USENET News System)
  6. Message-ID: <HEYDENJ.96Mar4095800@bothrops.natlab.research.philips.com>
  7. In-Reply-To: jtbell@presby.edu's message of Sun, 3 Mar 1996 18:10:40 GMT
  8. Date: Mon, 4 Mar 1996 08:58:00 GMT
  9. References: <4hchoh$ngh@nova.umuc.edu> <DnpEHt.BH3@presby.edu>
  10. Organization: Philips Semiconductors B.V.
  11.  
  12. But still...
  13.  
  14. <snip>
  15.  
  16. > >3. Is this the right way to right a file for a class in unix:
  17. > >
  18. > >    //FILE: EmpRecords.h
  19. > >       // MANIPULATES EMPLOYEE RECORDS
  20. > >       #ifdef EMPLOYEERECORDS_H_
  21.            ^^^^^
  22.                 should be ifndef instead!!!!
  23. > >       #define EMPLOYEERECORDS_H_
  24. > >
  25. > >    // class definition, and member function definitions
  26. > >                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^ <-- NO!
  27. > >    #endif//end of EmpRecords.h
  28.  
  29. The #ifndef / #define / #endif is used to prevent a single header to be
  30. included more then once (a header file might already be included in one of
  31. the other header files you include. A flag (EMPLOYEERECORDS_H_ in
  32. this case) is used to denote that a header file has been included. If this
  33. flag is not set (#ifndef), the definitions in the header are processed, AND the flag
  34. is set for further use (#define...) . If an attempt is made to include the header again,
  35. then the whole thing is skipped because of the #ifndef.
  36.  
  37. Just my $0.02 worth...
  38.             Jos.
  39.  
  40. --
  41.     J.W.B. van der Heijden, Philips Research Laboratories, Building WAY5.43
  42.     Prof. Holstlaan 4           5656 AA Eindhoven           The Netherlands
  43.     Phone: +31-40-2744351       E-mail: heydenj@natlab.research.philips.com
  44. -- 
  45.  
  46.     J.W.B. van der Heijden, Philips Research Laboratories, Building WAY5.43
  47.     Prof. Holstlaan 4           5656 AA Eindhoven           The Netherlands
  48.     Phone: +31-40-2744351       E-mail: heydenj@natlab.research.philips.com
  49.